# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2023年02月23日
"""

import docx
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from docx.shared import Pt

# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2023年02月23日
"""

import docx
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from docx.shared import Pt

myDocument = docx.Document('背诵名篇.docx')

myDocument.sections[1].header.is_linked_to_previous=False
myDocument.sections[2].header.is_linked_to_previous=False
myDocument.sections[3].header.is_linked_to_previous=False
myDocument.sections[1].even_page_header.is_linked_to_previous=False
myDocument.sections[2].even_page_header.is_linked_to_previous=False
myDocument.sections[3].even_page_header.is_linked_to_previous=False

myDocument.settings.odd_and_even_pages_header_footer=True
myParagraph1=myDocument.sections[1].header.paragraphs[0]
myParagraph1.text='这是第1节奇数页的页眉'
myParagraph1.alignment=WD_PARAGRAPH_ALIGNMENT.CENTER
myParagraph1.runs[0].font.size=Pt(12)

myParagraph11=myDocument.sections[1].even_page_header.paragraphs[0]
myParagraph11.text='这是第1节偶数页的页眉'
myParagraph11.alignment=WD_PARAGRAPH_ALIGNMENT.CENTER
myParagraph11.runs[0].font.size=Pt(12)

myDocument.save("02散文名篇.docx")



myDocument.save("02散文名篇.docx")

